﻿#!/usr/bin/env python3
import time

from main import main
from main import tester

#* 警告:由于作者正生病，本程序可能出现未完成的代码、错误的信息和误读等问题，且本程序将长期不更新。 *

version = "0.0.1dev.35.2" # 版本号
name = "XhsPyBio CLI  " + version # 版本号
varn = True # 决定程序的运行

class cmdmain():
    helphge = 1 # 当前页数（help页数）
    helpgnz = 1 # 总共页数（help页数）
    def cmdmain():
       # 临时警告
       print ("* 警告:由于作者正生病，本程序可能出现未完成的代码、错误的信息和误读等问题，且本程序将长期不更新。 *")
       # CMD main
       print ("XpBc*******----------*************@")
       print ("        *  XhsPyBio CLI  *")
       print ("  help : 帮助")
       print ("  about: 关于")
       print ("  exit : 退出")
       print (" 现在时间为:",time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
       print ("@*********************************@\n")
    def help(): # 帮助
        print ("help-------------------------------------╗")
        print (" drep（d）: DNApair功能")
        print (" tran（r）: RNApair功能")
        print (" abbr（a）: 查看分子结构式")
        print (" cf（c）: 自定义功能")
        print (" help（h-）: 帮助")
        print (" ensh: 设置是否显示具体信息")
        print (" uish: 设置风格")
        print (" cmd: 标题")
        print (" exit（q）: 退出")
        print (" res（r-）: 参考资料")
        print (" about（a-）: 关于")
        print ("    about v（a- v）: 更新日志")
        print ("               *注意大小写*")
        print ("╚----------------------------------------╝")
        print ("第",cmdmain.helpgnz,"/",cmdmain.helphge,"页")

class about():
    def about():
        # 关于
        print ("about------------------------------------------------------╗")
        print (" XhsPyBio CLI 极早期开发:",version,";")
        print (" 创作:Xhs44444100;")
        print (" 基于Python 3.12;")
        print (" 虽然有引用，但可能出现误读等理论错误;")
        print (" 本软件采用CC BY-SA 4.0协议授权。\n")
        print (" gitee: https://gitee.com/xhs44444100/molbiopycmd \n")
        print (" （更新日志请输入 about v ）")
        print ("╚-------------------------------------------------------XpBc")
    def about_v():
        # 更新日志
        print ("╔--------------------------------------------------------╗")
        print (" XhsPyBio CLI 极早期开发:", version, "\n")
        print ("  此版本为重大更新！")
        print ("  1.加入简称命令")
        print ("  2.修复bug")
        print ("  ......")
        print ("╚-----------------------------------------------------XpBc")
    
if __name__ == '__main__':
   ui = "[XpBc:]" # ui main
   ensh = True # 显示具体信息bool
   cmdmain.cmdmain()
   while varn == True:
      cin = input(ui) # 指令输入
      if cin == "cmd":
        cmdmain.cmdmain()
      elif cin == "help" or cin == "h-": # 帮助
          cmdmain.help()
      elif cin == "drep" or cin == "d": # DNApair功能
          main.dna.paircmd()
      elif cin == "tran" or cin == "r": # RNApair功能
          main.rna.paircmd()
      elif cin == "abbr" or cin == "a": # 查看分子结构式
          main.abbr()
      elif cin == "about" or cin == "a-": # 关于
          about.about()
      elif cin == "res" or cin == "r-": # 参考资料
          main.res()
      elif cin == "about v" or cin == "a- v": # 更新日志
          about.about_v()
      elif cin == "ensh":
          # 显示具体信息设置
          print ("显示具体信息（目前为",ensh,"）")
          ynensh = input("是否显示具体信息？【n/y】: ")
          if ynensh == "n":
              ensh = False
              print ("设置成功！（",ensh,"）")
          else:
              ensh = True
              print ("设置成功！（",ensh,"）")
      elif cin == "uish":
          # 风格设置
          uiyn = input("设置风格【os2、bash、cmd】: ")
          if uiyn == "bash":
              ui = "XpBc:$ "
              print ("设置成功！")
          elif uiyn == "cmd":
              ui = "XpBc:>"
              print ("设置成功！")
          else:
              ui = "[XpBc:]"
              print ("设置成功！")
      elif cin == "cf" or cin == "c":
          # CUSTOM功能
          try:
              from custom import custom
              name = "XhsPyBio CLI*  " + version
              cfdef = input("输入函数序号【1-4】: ")
              if cfdef == "1":
                  custom.say1(ensh)
              elif cfdef == "2":
                  custom.say2(ensh)
              elif cfdef == "3":
                  custom.say3(ensh)
              elif cfdef == "4":
                  custom.say4(ensh)
              else:
                  print ("非法序号！")
                  name = "XhsPyBio CLI  " + version
          except:
              print ("出现错误！可能是未找到文件或函数有错误。")
              name = "XhsPyBio CLI  " + version
      elif cin == "version" or cin == "v-":
          print (name)
      elif cin == "test":
          # TEST功能
          tester.test(ensh,version)
      elif cin == "exit" or cin == "q": # 退出程序运行
              exitn = input("真的要退出吗？【n/y】: ")
              if exitn == "y":
                  varn = False
      else:
          if cin != "":
              print ("未知指令! ")


# 《XhsPyBio CLI》
# 创作：Xhs44444100；
# 本程序采用CC BY-SA 4.0协议授权。